package controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import controller.action.Action;
import controller.action.MDAction;
import controller.action.PMAction;

public class FrontController extends HttpServlet{

	private static final long serialVersionUID = 1L;

	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html");
     
        if (request.getParameter("submit") != null) {
        	Action a = null;
        	
        	if ("+".equals(request.getParameter("submit")) || 
        	    "-".equals(request.getParameter("submit"))) {
        	
        		a = new PMAction();
        	
        	} else if (request.getParameter("submit").equals("/") || 
            	       request.getParameter("submit").equals("*")) {
        		
        		a = new MDAction();
        	
        	}
        	a.execute(request, response);
        }
	}
	
}